<!-- 功能：权限管理 | 作者：menghao.yan | 邮箱：yxs2615@163.com | 时间：2023年08月22日 22:53:39 -->
<template>
  <a-card>
    <a-row align="middle">
      <a-col :span="16">
        <a-space>
          <a-button type="link" class="y-btn" @click="openXinJianMuLuModal">
            <template #icon>
              <plus-outlined />
            </template>
            新建目录
          </a-button>
          <!-- 弹窗 - 新建目录 -->
        </a-space>
      </a-col>
      <a-col :span="8">
        <a-input v-model:value="searchValue">
          <template #addonBefore>
            <search-outlined /> 搜索:
          </template>
        </a-input>
      </a-col>
    </a-row>
    <a-table bordered :data-source="dataSource" :columns="columns" class="y-table" :pagination="pagination">
    </a-table>
  </a-card>
</template>

<script setup>
import { Modal } from 'ant-design-vue'
import { ExclamationCircleOutlined } from '@ant-design/icons-vue'
// -- 用户
const visibleXinJiaMuluuModal = ref(false)

const openXinJianMuLuModal = () => {
  visibleXinJiaMuluuModal.value = true

  Modal.info({
    title: '提示消息',
    icon: h(ExclamationCircleOutlined),
    content: '本地文件系统不支持权限管理!通过 磁盘管理>存储池管理>创建NASLUN>创建文件系统>挂载LUN 来使文件系统支持权限管理!',
    okText: '确定',
    onOk() {
      console.log('OK')
    }
  })
}

const searchValue = ref('')

// 表格列
const columns = ref([
  {
    title: '目录名',
    dataIndex: 'name',
    key: 'name',
    align: 'center',
    sorter: {
      compare: (a, b) => a.name.localeCompare(b.name),
      multiple: 1
    }
  },
  {
    title: '绝对路径',
    dataIndex: 'absolutePath',
    key: 'absolutePath',
    align: 'center',
    sorter: {
      compare: (a, b) => a.absolutePath.localeCompare(b.absolutePath),
      multiple: 2
    }
  },
  {
    title: '权限',
    children: [
      {
        title: '只读用户',
        dataIndex: 'readUser',
        key: 'readUser',
        align: 'center',
        sorter: {
          compare: (a, b) => a.readUser.localeCompare(b.readUser),
          multiple: 3
        }
      },
      {
        title: '可读/写的用户',
        dataIndex: 'readWriteUser',
        key: 'readWriteUser',
        align: 'center',
        sorter: {
          compare: (a, b) => a.readWriteUser.localeCompare(b.readWriteUser),
          multiple: 4
        }
      },
      {
        title: '只读组',
        dataIndex: 'readgroup',
        key: 'readgroup',
        align: 'center',
        sorter: {
          compare: (a, b) => a.readgroup.localeCompare(b.readgroup),
          multiple: 5
        }
      },
      {
        title: '可读/写的组',
        dataIndex: 'readWriteGroup',
        key: 'readWriteGroup',
        align: 'center',
        sorter: {
          compare: (a, b) => a.readWriteGroup.localeCompare(b.readWriteGroup),
          multiple: 6
        }
      }
    ]
  }
])

// 表格数据
const dataSource = ref([
  {
    key: '1',
    name: 'John Brown',
    readUser: 'john',
    readWriteUser: 'john',
    readgroup: 'john',
    readWriteGroup: 'john'
  },
  {
    key: '2',
    name: 'Jim Green',
    readUser: 'jim',
    readWriteUser: 'jim',
    readgroup: 'jim',
    readWriteGroup: 'jim'
  }
])

// 分页
const pagination = {
  current: 1,
  pageSize: 10,
  showQuickJumper: true,
  showSizeChanger: true,
  total: 0,
  showTotal: (total, range) => {
    return `${range[0]}-${range[1]} 共 ${total} 条数据`
  },
  onChange: (page, pageSize) => {
    console.log('权限管理分页改变>>', page, pageSize)
  }
}
</script>

<style scoped lang='scss'>
.ant-row {
  margin-bottom: 10px;
}
</style>